<?php
foreach($this->posts as $post){?>
<div class="message">
    <b><a href="/?author=<?=$post['author']['id']?>">
        <?=$post['author']['nick'];?>
    </a></b>
    <sup style='color: #888; font-size: 11px;'>
        <?=$post['author']['rating'];?>
    </sup>
    <input type="hidden" title="author" value="<?=$post['author']['id']?>">
    <?  if(!empty($this->user) && ($this->user->getId() != $post['author']['id']))
{?>
    <div class="star"><input type="hidden" value="<?=$post['author']['id']?>"></div>
    <?  }?>
    <div style="margin-left: 20px;">
        <?
        echo $post['text'];
        if(!empty($post['video']))
        {
            ?>
            <iframe src="<?=$post['video']?>" width="420" height="315" frameborder="0" webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen=""></iframe>
            <?
        }
        if(!empty($post['tags']))
        {
            echo "<div style='font-size: 11px; color: #888'>";
            foreach($post['tags'] as $tag)
            {
                echo "<a href='/?tag=" . $tag['id'] . "'>" . $tag['tag'] . "</a> ";
            }
            echo "</div>";
        }

        if(isset($this->user) && ($post['author']['id'] == $this->user->getId()))
        {
            ?>
            <div style="float: right; font-size: 12px; margin: 5px; color:#888">
                <a style="text-align: right; color: #AAA"  href="/message/edit?id=<?=$post['id']?>">Edit</a>
            </div>
            <div style="float: right; font-size: 12px; margin: 5px;">
                <a style="text-align: right; color: #AAA;" href="/message/delete?id=<?=$post['id']?>">Delete</a>
            </div>
            <?
        }

        if(!empty($post['comments']))
        {
            echo "<br><br>";
            foreach($post['comments'] as $comment)
            {
                ?>
                <div style=" padding: 5px; margin-right: 5px; font-size: 13px; background-color: #F1F1F1; ;width: 400px; float: right; border-top-width: 1px; border-top-color: #E8E8E8; border-top-style: solid;">
                    <b><a href="/?author=<?=$comment['author']['id']?>"><?=$comment['author']['nick']?></b></a><br>
                    <div style="margin-left: 20px; font-size: 14px;">
                        <?=$comment['text']?>
                    </div>
                </div>
                <?
            }
        }
        if(isSet($this->user))
        {
            ?>
            <div class="comment_panel">
                <div class="add_comment" style="color: #AAA">Add comment</div>
                <form style="text-align:left; display: none; margin: 0px; color:#888;" action="/comment/add" method="post">
                    <input type="hidden" value="<?=$post['id']?>" name="message">
                    <input type="hidden" value="<?=$this->user->getId()?>" name="author">
                    <input type="text" name="text" placeholder="Add comment here" style="width: 400px">
                    <input type="submit" value="Send">
                </form>
            </div>
            <?
        }
        ?>
    </div>
</div>
<?}
?>
